/**
 * create by young (young2f@outlook.com) on 2020/9/16
 */


'use strict';
import React from 'react';
import {Card, Form, Tabs} from 'antd';

import FormBase from '../../../components/Base/FormBase';
import {connect} from "dva";
import moment from 'moment';
import 'moment/locale/zh-cn';
import DescGroup from "../../../components/DescriptionGroup";
import ViewTitle from "../../../components/ViewTitle";
import _ from "lodash";

const {TabPane} = Tabs;
moment.locale('zh-cn');
const table = 'Work';
@Form.create()
@connect(({user, global, work}) => ({...user, ...work, ...global}))
export default class ModalTaskDetail extends FormBase {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {

  }

  getCard = (files) => {
    const temp = [];
    _.map(files, file => {
      temp.push(<Card
        hoverable
        style={{width: 640}}
        cover={<img alt="example" src={file.preview}/>}
      >
      </Card>);
    });
    return temp;
  };

  render() {
    const {style, cols = 2,model={}, workRecord = {}, form} = this.props;
    const {code, completionDesc, requiredCompletionDate, isEnded, workList,fileList, isAdmin} = workRecord;
    const _labels = _.filter(model, (item, key) => {
      if (_.includes(item.enableArea, 'detail')) {
        item.key = key;
        return item;
      }
    });
    const labels = [
      {label: '任务编码', key: "code",_type:'string'},

      {label: '事项', key: "desc",_type:'string'},
      // {label: '责任人', key: "username",_type:'string'},
      {label: '要求完成时间', key: "requiredCompletionDate",_type:'date'},
      {label: '实际完成时间', key: "completionDate",_type:'date'},
      {label: '完成情况', key: "completionDesc",_type:'string'},
      {label: '是否需要创建关联任务', key: "isRelation",_type:'string'},
      {label: '备注', key: "memo",_type:'string'},
    ];
    return (
      <div style={{...style}}>

            <ViewTitle
              title={'工作任务信息'}
              level={1}
            ></ViewTitle>
            <DescGroup
              {...{
                labels: labels,
                values: workRecord,
                size: 'small',
                column: cols
              }}
            ></DescGroup>

            {this.getCard(fileList)}


      </div>

    );
  }
}

